@charset "utf-8";
@import "classes";

/**
 * @class widget
 */

/**
 * 构造列表的自定义使用方法
 -----------------------
 * 使用方法，详见 [Demo](http://doyoe.github.io/Yo/demo/widget/yo-popup.html)
 * @method yo-popup
 * @param {default | String} $name 定义popup名称
 * @param {default | Length | null} $width 定义popup宽度
 * @param {default | Length} $height 定义popup高度
 * @param {default | Length} $radius 定义popup圆角
 * @param {default | Number} $shadow-opacity 定义popup阴影透明度
 * @param {default | Color} $bordercolor 定义popup边框色
 * @param {default | Length} $hd-height 定义popup头部高度
 * @param {default | Color} $hd-bgcolor 定义popup头部背景色
 * @param {default | Color} $title-color 定义popup标题文本色
 * @param {default | Length} $title-font-size 定义popup标题字号
 * @param {default | Length} $bd-padding 定义popup主体补白
 * @param {default | Length} $arrow-size 定义popup箭头高度
 */

@mixin yo-popup(
    $name: default,
    $width: default,
    $height: default,
    $radius: default,
    $shadow-opacity: default,
    $bordercolor: default,
    $hd-height: default,
    $hd-bgcolor: default,
    $title-color: default,
    $title-font-size: default,
    $bd-padding: default,
    $arrow-size: default) {
    // 区别是否新增实例还是修改本身
    @if $name == default {
        $name: "";
    } @else {
        $name: "-#{$name}";
    }
    // 如果值为default，则取config的定义
    @if $width == default {
        $width: map-get($popup, width);
    }
    @if $height == default {
        $height: map-get($popup, height);
    }
    @if $radius == default {
        $radius: map-get($popup, radius);
    }
    @if $bordercolor == default {
        $bordercolor: map-get($popup, bordercolor);
    }
    @if $shadow-opacity == default {
        $shadow-opacity: map-get($popup, shadow-opacity);
    }
    @if $hd-height == default {
        $hd-height: map-get($popup, hd-height);
    }
    @if $hd-bgcolor == default {
        $hd-bgcolor: map-get($popup, hd-bgcolor);
    }
    @if $title-color == default {
        $title-color: map-get($popup, title-color);
    }
    @if $title-font-size == default {
        $title-font-size: map-get($popup, title-font-size);
    }
    @if $bd-padding == default {
        $bd-padding: map-get($popup, bd-padding);
    }
    @if $arrow-size == default {
        $arrow-size: map-get($popup, arrow-size);
    }
    .yo-popup#{$name} {
        > .arrow::after{
            @if $arrow-size != map-get($popup, arrow-size) {
                font-size: $arrow-size * 2;
            }
        }
        .arrow-top::after{
            @if $arrow-size != map-get($popup, arrow-size) {
                top: -$arrow-size + .01rem;
            }
            @if $bordercolor != map-get($popup, bordercolor) {
                text-shadow: 0 -1px $bordercolor;
            }
        }
        .arrow-down::after {
            @if $arrow-size != map-get($popup, arrow-size) {
                bottom: -$arrow-size + .01rem;
            }
            @if $bordercolor != map-get($popup, bordercolor) {
                text-shadow: 0 1px $bordercolor;
            }
        }
        .arrow-right::after {
            @if $arrow-size != map-get($popup, arrow-size) {
                right: -$arrow-size + .01rem;
            }
            @if $bordercolor != map-get($popup, bordercolor) {
                text-shadow: 1px 0 $bordercolor;
            }
        }
        .arrow-left::after {
            @if $arrow-size != map-get($popup, arrow-size) {
                left: -$arrow-size + .01rem;
            }
            @if $bordercolor != map-get($popup, bordercolor) {
                text-shadow: -1px 0 $bordercolor;
            }
        }
        .arrow-extra.arrow::after {
            @if $hd-bgcolor != map-get($popup, hd-bgcolor) {
                color: $hd-bgcolor;
            }
        }
        @if $radius != map-get($popup, radius) {
            border-radius: $radius;
        }
        @if $bordercolor != map-get($popup, bordercolor) {
            border-color: $bordercolor;
            box-shadow: 0 0 5px rgba($bordercolor, $shadow-opacity);
        } @else {
            @if $shadow-opacity != map-get($popup, shadow-opacity) {
                box-shadow: 0 0 5px rgba($bordercolor, $shadow-opacity);
            }
        }
        @if $width != map-get($popup, width) {
            width: $width;
        }
        @if $height != map-get($popup, height) {
            height: $height;
        }
        > .hd {
            @if $radius != map-get($popup, radius) {
                border-radius: $radius $radius 0 0;
            }
            @if $hd-height != map-get($popup, hd-height) {
                height: $hd-height;
                line-height: $hd-height;
            }
            @if $bordercolor != map-get($popup, bordercolor) {
                border-bottom-color: $bordercolor;
            }
            @if $hd-bgcolor != map-get($popup, hd-bgcolor) {
                background: $hd-bgcolor;
            }
            .title {
                @if $title-color != map-get($popup, title-color) and $title-color != map-get($base, color) {
                    color: $title-color;
                }
                @if $title-font-size != map-get($popup, title-font-size) and $title-font-size != map-get($base, font-size) {
                    font-size: $title-font-size;
                }
            }
        }
        > .bd {
            @if $bd-padding != map-get($popup, bd-padding) {
                padding: $bd-padding;
            }
        }
        > .ft {
            @if $bordercolor != map-get($popup, bordercolor) {
                border-color: $bordercolor;
            }
        }
        // 增量扩展
        @content;
    }
}

// 调用本文件时载入popup基础构造
.yo-popup {
    @include _popup;
}